package com.yuanfengPlus.goodsManage.goodsBrandManage.service.Impl;

import com.yuanfengPlus.goodsManage.goodsBrandManage.dao.GoodsBrandDao;
import com.yuanfengPlus.goodsManage.goodsBrandManage.model.GoodsBrand;
import com.yuanfengPlus.goodsManage.goodsBrandManage.service.GoodsBrandService;
import com.yuanfengPlus.utils.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class GoodsBrandServiceImpl implements GoodsBrandService {

    @Autowired
    private GoodsBrandDao goodsBrandDao;

    @Override
    public Result addGoodsBrand(GoodsBrand goodsBrand) {
        int rows = goodsBrandDao.addGoodsBrand(goodsBrand);
        return rows > 0 ? Result.success("添加成功") : Result.failure(400,"添加失败");
    }


    @Override
    public Result updateGoodsBrand(GoodsBrand goodsBrand) {
        int rows = goodsBrandDao.updateGoodsBrand(goodsBrand);
        return rows > 0 ? Result.success("更新成功") : Result.failure(400,"更新失败");
    }

    @Override
    public Result queryGoodsBrand() {
        List<GoodsBrand> goodsBrands = goodsBrandDao.queryGoodsBrand();
        return Result.success(goodsBrands);
    }

    @Override
    public Result queryGoodsBrandById(Integer goodsBrandId) {
        GoodsBrand goodsBrand = goodsBrandDao.queryGoodsBrandById(goodsBrandId);
        return goodsBrand != null ? Result.success(goodsBrand) : Result.failure(400 ,   "未找到");
    }
}
